#ifndef SERIALPORTTHREAD_H
#define SERIALPORTTHREAD_H

#include <QObject>
#include <QThread>
#include <QDebug>
#include <QSerialPortInfo>
#include <QSerialPort>
#include "loghelper.h"
#include <CommonHelper.h>

class SerialportThread:public QSerialPort
{
    Q_OBJECT;
public:
    static SerialportThread* getInstance();
    explicit SerialportThread(QObject *parent = nullptr);
    QString experimentStatus="";

public:
    void ClientConnectToHost(const QString &address, QString port);
    void ClientSendingData(const QByteArray &c_btaData);
    void serialclose();
    bool IsOnline();

signals:
    //转换来自主线程的链接操作
    void SignalConnectToHost(const QString & address, QString port);
    //转换来自主线程的发送操作
    void SignalSendingData(const QByteArray c_btaData);

private:
    QThread thread;
    static SerialportThread* Instance ;
    loghelper * logClient;
    CommonHelper* common;
    QString tempString;
    QMap<QString, QString> *mapGZ;
    bool m_bOnLine;
};

#endif // SERIALPORTTHREAD_H
